home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8916 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: solon.com!not-for-mail
  2. From: seebs@solutions.solon.com (Peter Seebach)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Schildt <- Advanced Books
  5. Date: 6 Mar 1996 19:42:33 -0600
  6. Organization: Usenet Fact Police (Undercover)
  7. Message-ID: <4hleu9$5ah@solutions.solon.com>
  8. References: <8BA8405.02C70020DE.uuout@sourcebbs.com> <danpop.825687663@rscernix> <4he6hb$ahn@solutions.solon.com> <danpop.826121528@rscernix>
  9. NNTP-Posting-Host: solutions.solon.com
  10.  
  11. In article <danpop.826121528@rscernix>, Dan Pop <danpop@mail.cern.ch> wrote:
  12. >"%f" might be a typo (yet it was preserved between editions, so maybe
  13. >it was not a typo :-) but the missing cast _cannot_ be a typo.
  14.  
  15. Well, maybe a very *large* typo.
  16.  
  17. >There is nothing subtle here, for someone who knows C (which rules Schildt
  18. >out :-)  size_t is _guaranteed_ not to be defined as int, so using "%d"
  19. >is plain idiotic.  I could understand a "%u", and qualify the author as
  20. >mildly stupid :-)
  21.  
  22. I consider a bug subtle if the code is likely to work correctly most of the
  23. time.
  24.  
  25. >Every single bit as idiotic as "%d" for size_t.  Under special 
  26. >circumstances, both give the "correct" results.  At least, sizeof(ptr)
  27. >doesn't invoke undefined behaviour :-)
  28.  
  29. Curious; less likely to work, yet more legal.  :)
  30.  
  31. Mostly, I object to the specific explanation offered that the sizeof(ptr)
  32. thing will correctly get the size of the alleged array.
  33.  
  34. Hmm.  Is it really legal to write just part of an object?  Hmm.  I suppose
  35. it is, just not useful.
  36.  
  37. Actually, come to think of it, the attempt to write sizeof(int *) bytes
  38. from what is expected to be an array of 6 ints may be undefined; assuming,
  39. that is, that sizeof(int *) is > 6 * sizef(int).
  40.  
  41. :)
  42.  
  43. -s
  44. -- 
  45. Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach.
  46. C/Unix wizard -- C/Unix questions? Send mail for help.  No, really!
  47. FUCK the communications decency act.  Goddamned government.  [literally.]
  48. The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
  49.